#import "PaintScrollView.h"
#import "PaintDocView.h"
#import "PaintLabParams.h"

#import <appkit/Control.h>
#import <appkit/Matrix.h>

@implementation PaintScrollView

+newFrame:(const NXRect *)tF
{
	NXRect docRect;
	id myDocView;
	
	// Create the newScrollView
	self = [super newFrame:tF];
        [[self setVertScrollerRequired:YES]
	       setHorizScrollerRequired:YES];
	
	// Create and install the docView
	NXSetRect(&docRect, 0.0, 0.0, DOC_WIDTH, DOC_HEIGHT);
	myDocView = [PaintDocView newFrame:&docRect];
	[self setDocView:myDocView];
	
	return self;
}


//
// This method is automatically created by the Interface Builder
// because the class description for a PaintScrollView has an outlet
// called "brushSizeText."  At runtime (during execution of
// loadNibFile::) this method is automatically called to set the
// value of the brushSizeText instance variable to be the id of
// whatever object was connected to the outlet.
//
// The right object to connect to the outlet is the text object
// which will reflect the value of the brush-size slider.
//

- setBrushSizeText:anObject
{
    brushSizeText = anObject;
    return self;
}


//
// The next four methods (clear:, setBrushShape:, setBrushSize:,
// and setPaintColor:) just send their parameters on to the
// docView, which does the real work.
//

- clear:sender
{
	[[self docView] clear];
        return self;
}



- setBrushShape:sender		// Sender is a radio-button array
{
	int shape;
	
	shape = [sender selectedRow];
	[[self docView] setDocBrushShape:shape];
	return self;
}

- setBrushSize:sender		// sender is a slider
{
	float brushSize;
	
	brushSize = (float)[sender intValue];
	[brushSizeText setFloatValue:brushSize];
	[[self docView] setDocBrushSize:brushSize];
	return self;
}

- setPaintColor:sender		// sender is a radio-button array
{
	float color_array[] = {NX_BLACK, NX_DKGRAY, NX_LTGRAY, NX_WHITE};
	
	// Double square brackets!  The outer ones are for array
	// indexing, the inner ones are a method call.
	[[self docView] setDocPaintColor:color_array[[sender selectedRow]]];
	return self;
}




@end
